<template>
    <el-dialog
            title="编辑"
            :visible.sync="dialogVisible"
            width="30%"
            :before-close="complie">
        <el-form :label-position="labelPosition" label-width="80px" :model="parkMember">
            <el-form-item label="园区名称">
                <el-input v-model="parkMember.parkArea"></el-input>
            </el-form-item>
            <el-form-item label="所在校区">
                <el-input v-model="parkMember.campus"></el-input>
            </el-form-item>
            <el-form-item label="楼栋数量">
                <el-input v-model="parkMember.number"></el-input>
            </el-form-item>
            <el-form-item label="房间总数">
                <el-input v-model="parkMember.room" disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="床位总数">
                <el-input v-model="parkMember.bed" disabled="true"></el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="submit">确 定</el-button>
  </span>
    </el-dialog>
</template>

// 是否需要表单验证？

<script>
import {editPark} from '../../../../api/park'
export default {
  name: 'ParkAdd',
  data: function () {
    return {
      dialogVisible: false,
      labelPosition: 'right',
      parkMember: {}
    }
  },
  methods: {
    show (men) {
      // 与传过来的是同一个地址，需要进行克隆
      // 将对象先json字符串化，再json对象化
      this.dialogVisible = true
      this.parkMember = JSON.parse(JSON.stringify(men))
    },
    submit () {
      editPark(this.parkMember).then(res => {
        if (res.data === true) {
          this.$message({
            type: 'success',
            message: '修改成功!'
          })
          this.dialogVisible = false
          this.$emit('ok')
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
